<template>
  <el-form label-position="left" label-width="0px" class="demo-ruleForm login-container">
    <h3 class="title">礼品淘管理后台系统</h3>
    <el-form-item>
   <el-input prefix-icon="el-icon-mobile" placeholder="账号" v-model="account"> </el-input>
    </el-form-item>
    <el-form-item>
     <el-input prefix-icon="el-icon-lock" type="password" show-password placeholder="密码" v-model="password"> </el-input>
    </el-form-item>
     <el-form-item style="width:100%;">
      <el-button type="primary" style="width:100%;" @click="login" >登录</el-button> 
       </el-form-item>
  </el-form>
</template>

<script>
  // import { requestLogin } from '../api/api';
  import routes from "../routes";  
  import {hex_md5} from "../utils/md5"; 
  import axios from "axios" 

  export default {
    data() {
     return {
      account:'',
      password:''
    };
    },
    methods: { 
   login(){  
      
          
     let that=this;  
     this.axios.post('/sysUser/login',
     this.qs.stringify({
          account:this.account,
          password:hex_md5(this.password)
      }),{
          headers: {
            'Content-Type':'application/x-www-form-urlencoded',
            'domain':'taobao.tianyalei.com'
          }
        })
      .then(function (response) { 
        //  console.log(response,that)
         
          if(response.data.code==200){
            //  let { msg, code, user } = data;
            //  that.$router.replace({name:'Table'}); 
            //  console.log(that.$router)
             //登陆成功       
              that.$message({
                message:'登录成功',
                type: 'success'
              }); 
               sessionStorage.setItem('token',response.data.data);
              //跳转  
               that.$router.replace({name:'业务概括'});
          }else{ 
              that.$message({
                message: response.data.message,
                type: 'warning' 
              });
          }
        })
        .catch((error)=>{  
          // console.log(error) 
        })
      },
 
    }
  }

</script>

<style lang="scss" scoped>
  .login-container {
    /*box-shadow: 0 0px 8px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02);*/
    -webkit-border-radius: 5px;
    border-radius: 5px;
    -moz-border-radius: 5px;
    background-clip: padding-box;
    margin: 180px auto;
    width: 350px;
    padding: 35px 35px 15px 35px;
    background: #fff;
    border: 1px solid #eaeaea;
    box-shadow: 0 0 25px #cac6c6;
    .title {
      margin: 0px auto 40px auto;
      text-align: center;
      color: #505458;
    }
    .remember {
      margin: 0px 0px 35px 0px;
    }
  }
</style>